using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Sys_File - 大文件表 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class ISysFile<T> :ModelBase<SysFile> where T : SysFile, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.FlieId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return FlieId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.FlieId=dy.FlieId;
           this.ModelId=dy.ModelId;
           this.FlieName=dy.FlieName;
           this.FileSize=dy.FileSize;
           this.Extension=dy.Extension;
           this.SubmitTime=dy.SubmitTime;
           this.SavePath=dy.SavePath;
           this.IsDel=dy.IsDel;
           this.DownCount=dy.DownCount;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 文件ID
        /// </summary>
        private String _FlieId = "";
      
        /// <summary>
        /// 文件ID
        /// </summary>
        public String FlieId
        {
            get 
            {
              return   (this._FlieId); 
            }

            set 
            {
                    _FlieId= value;  
            }
        }
       
     
         /// <summary>
        /// 关联ID
        /// </summary>
        private String _ModelId = "";
      
        /// <summary>
        /// 关联ID
        /// </summary>
        public String ModelId
        {
            get 
            {
              return   (this._ModelId); 
            }

            set 
            {
                    _ModelId= value;  
            }
        }
       
     
         /// <summary>
        /// 文件名
        /// </summary>
        private String _FlieName = "";
      
        /// <summary>
        /// 文件名
        /// </summary>
        public String FlieName
        {
            get 
            {
              return   (this._FlieName); 
            }

            set 
            {
                    _FlieName= value;  
            }
        }
       
     
         /// <summary>
        /// 大小
        /// </summary>
        private int _FileSize =int.MinValue;
      
        /// <summary>
        /// 大小
        /// </summary>
        public int FileSize
        {
            get 
            {
              return   (this._FileSize); 
            }

            set 
            {
                    _FileSize= value;  
            }
        }
       
     
         /// <summary>
        /// 扩展名
        /// </summary>
        private String _Extension = "";
      
        /// <summary>
        /// 扩展名
        /// </summary>
        public String Extension
        {
            get 
            {
              return   (this._Extension); 
            }

            set 
            {
                    _Extension= value;  
            }
        }
       
     
         /// <summary>
        /// 创建时间
        /// </summary>
        private DateTime _SubmitTime =DateTime.MinValue;
      
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime SubmitTime
        {
            get 
            {
              return   (this._SubmitTime); 
            }

            set 
            {
                    _SubmitTime= value;  
            }
        }
       
     
         /// <summary>
        /// 保存路径
        /// </summary>
        private String _SavePath = "";
      
        /// <summary>
        /// 保存路径
        /// </summary>
        public String SavePath
        {
            get 
            {
              return   (this._SavePath); 
            }

            set 
            {
                    _SavePath= value;  
            }
        }
       
     
         /// <summary>
        /// 是否删除
        /// </summary>
        private int _IsDel =-1;
      
        /// <summary>
        /// 是否删除
        /// </summary>
        public yq.Enums.BooleanType IsDel
        {
            get 
            {
              return  (yq.Enums.BooleanType)_IsDel; 
            }

            set 
            {
                    _IsDel= value.GetHashCode(); 
            }
        }
       
     
         /// <summary>
        /// 下载次数
        /// </summary>
        private int _DownCount =int.MinValue;
      
        /// <summary>
        /// 下载次数
        /// </summary>
        public int DownCount
        {
            get 
            {
              return   (this._DownCount); 
            }

            set 
            {
                    _DownCount= value;  
            }
        }
       
     
     
       

      #endregion 定义属性 

          protected internal override void SetValue(SysFile info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["FlieId"]!= DBNull.Value)
                  {
                  info.FlieId=row["FlieId"].ToString();
                 }
                 
                  
                  if(row["ModelId"]!= DBNull.Value)
                  {
                  info.ModelId=row["ModelId"].ToString();
                 }
                 
                  
                  if(row["FlieName"]!= DBNull.Value)
                  {
                  info.FlieName=row["FlieName"].ToString();
                 }
                 
                  
                  if(row["FileSize"]!= DBNull.Value)
                  {
                  info.FileSize=Convert.ToInt32(row["FileSize"]);
                 }
                 
                  
                  if(row["Extension"]!= DBNull.Value)
                  {
                  info.Extension=row["Extension"].ToString();
                 }
                 
                  
                  if(row["SubmitTime"]!= DBNull.Value)
                  {
                  info.SubmitTime=Convert.ToDateTime(row["SubmitTime"]);
                 }
                 
                  
                  if(row["SavePath"]!= DBNull.Value)
                  {
                  info.SavePath=row["SavePath"].ToString();
                 }
                 
                  
                  if(row["IsDel"]!= DBNull.Value)
                  {
                  info.IsDel= (yq.Enums.BooleanType)(row["IsDel"]) ;
                 }
                 
                  
                  if(row["DownCount"]!= DBNull.Value)
                  {
                  info.DownCount=Convert.ToInt32(row["DownCount"]);
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, SysFile info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@FlieId", DbType.String,ParameterTool.GetObj( info._FlieId )); 
            
             
                cn.AddInParameter(comm, "@ModelId", DbType.String,ParameterTool.GetObj( info._ModelId )); 
            
             
                cn.AddInParameter(comm, "@FlieName", DbType.String,ParameterTool.GetObj( info._FlieName )); 
            
             
                cn.AddInParameter(comm, "@FileSize", DbType.Int32,ParameterTool.GetObj( info._FileSize )); 
            
             
                cn.AddInParameter(comm, "@Extension", DbType.String,ParameterTool.GetObj( info._Extension )); 
            
             
                cn.AddInParameter(comm, "@SubmitTime", DbType.DateTime,ParameterTool.GetObj( info._SubmitTime )); 
            
             
                cn.AddInParameter(comm, "@SavePath", DbType.String,ParameterTool.GetObj( info._SavePath )); 
            
             
                cn.AddInParameter(comm, "@IsDel", DbType.Int32,ParameterTool.GetObj( info._IsDel )); 
            
             
                cn.AddInParameter(comm, "@DownCount", DbType.Int32,ParameterTool.GetObj( info._DownCount )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 